package dp;

public class SubarrayProductLessThanK713 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        if (nums.length <= 0) {
            return 0;
        }
        int result = 0;
        int slow = 0;
        int quick = 0;
        int temp = 1;

        while (slow < nums.length &&slow<=quick) {
            while (temp < k && quick < nums.length) {
                temp = temp * nums[quick++];
            }
            result += quick==nums.length? quick - slow: quick - slow-1;
            temp = temp / nums[slow];
            slow++;

        }
        return result;
    }
}
